<extend name="./base" />
<block name="pageContent">
    <link rel="stylesheet" href="{$Think.config.DOMAIN_URL}/Public/AdminTpl/css/s-settle.css">
    <div class="main-content">
        <!-- 头部面包屑导航条 -->
        <div class="breadcrumbs" id="breadcrumbs">
            <!--导航路径列表-->
            <ul class="breadcrumb no-margin-left">
                <li>
                    <a>管理后台</a>
                </li>
                <li class="action">
                    我的学堂
                </li>
            </ul>
        </div>
        <!--页面容器-->
        <div class="page-content">
            <div class="nav-tab" style="position: relative">
                <ul class="nav-tab-title ">
                    <li class="nav-this">课程列表</li>
                </ul>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <form class="form-horizontal s_input-bgcolor" method="post" action="{$Think.config.DOMAIN_URL}/course/index">
                        <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12 pad-b20">
                            <div class="form-group">
                                <label class="col-sm-3 control-label text-right no-padding-right">状态： </label>
                                <div class="col-sm-8">
                                    <select class="form-control" name="status">
                                        <option value="0">全部状态</option>
                                        <option value="1" <eq name="postArr.status" value="1">selected</eq>>已发布</option>
                                        <option value="2" <eq name="postArr.status" value="2">selected</eq>>未发布</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12 pad-b20">
                            <div class="form-group">
                                <label class="col-sm-3 control-label text-right no-padding-right"
                                       for="form-field-1-1">课程标题： </label>
                                <div class="col-sm-8">
                                    <input type="text" id="form-field-1-1" placeholder="新闻标题"
                                           class="form-control" name="name" value="{$postArr.name}">
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12 pad-b20">
                            <div class="form-group">
                                <label class="col-sm-3 control-label text-right no-padding-right">添加时间： </label>
                                <div class="col-sm-8">
                                    <div class="input-daterange input-group">
                                        <input type="text" class="input-sm form-control" placeholder="开始时间"
                                               name="start" id="start" value="{$postArr.start}">
                                        <span class="input-group-addon" style="background: none;border: none;">
																	-
																</span>
                                        <input type="text" class="input-sm form-control" placeholder="结束时间"
                                               name="end" id="end" value="{$postArr.end}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12 pad-b20 text-right">
                            <a href="{$Think.config.DOMAIN_URL}/course/addCourse" class="btn"
                               style="width: 120px;    border-radius: 2rem; background: #36c724!important;border-color: #36c724;margin-left: 20px;">
                                新增
                            </a>
                            <button type="submit" class="btn "
                                    style="width: 120px; border-radius: 2rem; background: #fba40a!important;border-color: #fba40a;margin-left: 20px;">
                                查询
                            </button>
                        </div>
                    </form>
                    <div class="space"></div>
                    <div class="row">
                        <div class="col-xs-12">
                            <table id="sample-table-1"
                                   class="table table-hover">
                                <thead>
                                <tr>
                                    <th class="center">课程标题</th>
                                    <th class="center">课程封面</th>
                                    <th class="center">分类</th>
                                    <th class="center">添加时间</th>
                                    <th class="center">状态</th>
                                    <th class="center" style="width:150px;">操作</th>
                                    <th class="center">排序</th>
                                </tr>
                                </thead>
                                <tbody>
                                <empty name="resList">
                                    <tr class="s_tr-vertical">
                                        <td colspan="7" class="center" style="color: red;">没有查询到结果</td>
                                    </tr>
                                </empty>
                                <volist  name="resList" id="vo">
                                    <tr class="s_tr-vertical">
                                        <td class="center">{$vo.title}</td>
                                        <td class="center"><img src="{$vo.cover_img}" style="width: 80px;height:80px"/></td>
                                        <td class="center">{$allType[$vo[one_typeid]]} / {$allType[$vo[two_typeid]]}</td>
                                        <td class="center">{$vo.addtime}</td>
                                        <eq name="vo.status" value="1">
                                            <td class="center">已发布</td>
                                        <else />
                                            <td class="center">未发布</td>
                                        </eq>
                                        <td class="s_order-fun left s_order-funmargin">
                                            <span><a href="{$Think.config.DOMAIN_URL}/course/editCourse?id={$vo.id}&page={$page}">编辑</a></span>
                                            <eq name="vo.status" value="1">
                                                <span onclick="freezeMg({$vo.id},{$vo.status})">撤回</span>
                                            <else />
                                                <span onclick="freezeMg({$vo.id},{$vo.status})">发布</span>
                                            </eq>
                                            <span class="s_shop-delete" onclick="delMg({$vo.id})">删除</span>
                                        </td>
                                        <td class="center"><input type="text" value="{$vo.sort}" onblur="editSort(this,{$vo.id})" class="seat"></td>
                                    </tr>
                                </volist>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="text-center">
                {$pageShow}
            </div>
        </div>
    </div>

    <script>
        laydate.render({
            elem: '#start' //指定元素
        });
        laydate.render({
            elem: '#end' //指定元素
        });
        //冻结解冻
        function freezeMg(id,status){
            var content = '确定要撤回吗？';
            var cls = 'fa-lock';
            if(status==2){
                content = '确定要发布吗？';
                cls = 'fa-unlock';
            }
            $.popup({
                type: 1,
                content: content,
                cls:cls,
                callback: function () {
                    $.popup.proto.close();
                    location.href = '/course/freezeCourse?id='+id+'&status='+status+'&page='+{$page};
                }
            });
        }
        //删除
        function delMg(id){
            $.popup({
                type: 1,
                content: "确定要删除吗？",
                cls:'fa-trash-o',
                callback: function () {
                    $.popup.proto.close();
                    location.href = '/course/delCourse?id='+id+'&page='+{$page};
                }
            });
        }
        //改变排序
        function editSort(that,id){
            $.ajax({
                type:"post",
                dataType:"json",
                url:"/course/editCourseSort",
                data:{
                    id: id,
                    sort: $(that).val()
                },
                success:function(data){
                    if(data.code == 0){
                        layer.msg('操作成功', {icon: 6,time: 1000});
                    }
                }
            });
        }
    </script>
</block>